<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		    <link rel="stylesheet" href="bower_components/layer/layer.css" />
		
		<script src="bower_components/jquery/dist/jquery.min.js"></script>
		<script src="bower_components/layer/layer.js"></script>
		<script type="text/javascript" src="js/jq.cookie.js" ></script>
	</head>
	<style>
		div{
			width: 340px;
			text-align: center;
		}
		table{
			width: 100%;
			border-collapse: collapse;
		}
		tr td:nth-of-type(2){
			border-bottom: solid 1px black;
			height: 40px;
		}
		tr td:nth-of-type(1){
			height: 35px;
			text-align:center;
		}
		table input{
			height: 40px;
			border: none;
		}
		#submit_btn{
			border: none;
			height: 35px;
		}
    body .demo-class .layui-layer-title{background:#3c8dbc; color:#fff; border: none;}
		body .demo-class .layui-layer-btn{border-color:1px solid #eea2bb}
		body .demo-class .layui-layer-btn a{background:white;}
		body .demo-class .layui-layer-btn .layui-layer-btn0{background:#3c8dbc;border:none;}
		body .demo-class .layui-layer-btn .layui-layer-btn1{background:#ffffff;}		
	</style>
	<body>
		<div>
		<table>
			<tr><td>品牌</td><td><input type="text" style="width:100%;"/></td></tr>
			<tr><td>品名</td><td><input type="text" style="width:100%;"/></td></tr>
			<tr><td>条码</td><td><input type="text" style="width:100%;"/></td></tr>
			<tr><td>规格</td><td><input type="text" style="width:100%;"/></td></tr>
			<tr><td>色号</td><td><input type="text" style="width:100%;"/></td></tr>
			<tr><td>供应商</td><td><input type="text" style="width:100%;"/></td></tr>
			<tr><td>销售单价</td><td><input type="text" style="width:100%;"/></td></tr>
		</table>
		
		<!--<input class="submit_btn" type="button"  value="提交"/>-->
			<button type="button" id="submit_btn" class="ui button" style="background: #3c8dbc;color: white;cursor: pointer;width: 100px;margin-top:50px;margin-left:40px;">提交</button>
		
		</div>
	</body>
</html>
<script>
	$(document).ready(function(){
		var index = parent.layer.getFrameIndex(window.name);  
		$("#submit_btn").click(function(){
			var inforArr=[];
		for (var i = 0; i<$("table").find("input").length;i++) {
			
			inforArr.push($("table").find("input").eq(i).val());
			
		}
		
			if (inforArr[0]=='') {
  					parent.layer.alert('请填写品牌',{skin:"demo-class"}); 				
			} else if(inforArr[1]==''){
  					parent.layer.alert('请填写品名',{skin:"demo-class"}); 				
			}else if(inforArr[2]==''){
  					parent.layer.alert('请填写条码',{skin:"demo-class"}); 				
			}else if(inforArr[3]==''){
  					parent.layer.alert('请填写规格',{skin:"demo-class"}); 				
			}else if(inforArr[4]==''){
  					parent.layer.alert('请填写色号',{skin:"demo-class"}); 				
			}else if(inforArr[5]==''){
  					parent.layer.alert('请填写供应商',{skin:"demo-class"}); 			
			}else if(inforArr[6]==''){
  					parent.layer.alert('请填写销售单价',{skin:"demo-class"}); 			
			}else{
					$.ajax({
							type:"get",
							url:"http://www.duoweish.com/apis/NewProduct/",
//							async:true,
							data:{
								Info:inforArr.join('*@*')
							},
							success:function(data){
							if(data=='failure'){
  								layer.msg('产品已存在,请重试');
																  									
							}else{
								var Tr = '<tr><td pro_id="'+data+'">'+inforArr[1]+'</td><td>'+inforArr[2]+'</td><td>'+inforArr[3]+'</td><td>'+inforArr[4]+'</td><td><input class="delect" type="button" value="删除"/></td></tr>';
								parent.$(".data2").append(Tr);
  								parent.layer.msg('新建成功',{time:'500'},function(){
  								parent.layer.closeAll();
  								});
							}
							} 
						});
			}
		
		
	})
	})
</script>